from fastapi import Depends, APIRouter
from sqlalchemy.orm import Session
from app.db import get_db
from app.schemas.workflow import WorkflowData
from app.handlers.workflows import save_workflow_handler, run_workflow_handler

router = APIRouter()

@router.post("/workflows")
async def save_workflow(data: WorkflowData, db: Session = Depends(get_db)):
    return await save_workflow_handler(data, db)

@router.post("/workflows/{workflow_id}/run")
async def run_workflow(workflow_id: int, db: Session = Depends(get_db)):
    return await run_workflow_handler(workflow_id, db)